package com.lzx.iteam.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.lzx.iteam.R;
import com.lzx.iteam.bean.SecretaryBean;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * **********************************
 * User: zhangshuai
 * Date: 2016年 05月 13日
 * Time: 下午5:21
 *
 * @QQ : 1234567890
 * **********************************
 */
public class SecretaryAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<SecretaryBean> mDatas;

    public SecretaryAdapter(Context mContext) {
        this.mContext = mContext;
    }

    public void bindData(ArrayList<SecretaryBean> datas){
        this.mDatas = datas;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return mDatas==null?0:mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.secretary_item_layout,null);
            holder.textMsg = (TextView) convertView.findViewById(R.id.secretary_tv_item_msg);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }

        SecretaryBean data = mDatas.get(position);
        holder.textMsg.setText(data.getPush_title());
        return convertView;
    }
    class ViewHolder{
        TextView textMsg;
    }
}
